package com.cch.examSystem.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import com.cch.examSystem.entity.Scale;

public class StudentMainServlet extends HttpServlet {

	/**
	 * The doGet method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to
	 * post.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=utf-8");
		PrintWriter out = response.getWriter();
		SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss");

		Scale s1 = new Scale();
		Scale s2 = new Scale();
		Scale s3 = new Scale();
		Scale s4 = new Scale();
		String sb = "[{\"scale_id\":\"001\",\"name\":\"三大测试题\",\"test_time\":\"02:00:00\",\"manager_name\":\"孙悟空\",\"total_score\":100},{\"scale_id\":\"002\",\"name\":\"三大测试题\",\"test_time\":\"02:00:00\",\"manager_id\":4,\"total_score\":100},{\"scale_id\":\"004\",\"name\":\"三大测试题\",\"test_time\":\"02:00:00\",\"manager_id\":4,\"total_score\":100},{\"scale_id\":\"005\",\"name\":\"三大测试题\",\"test_time\":\"02:00:00\",\"manager_id\":4,\"total_score\":100},{\"scale_id\":\"006\",\"name\":\"三大测试题\",\"test_time\":\"02:00:00\",\"manager_id\":4,\"total_score\":100}]";
		out.print(sb);
		/*
		 * s1.setName("三大测试题"); s1.setScale_id(1);
		 * s1.setTest_time(time.parse("02:00:00")); s1.setTotal_score(100);
		 * s1.setManager_id(4); s2.setName("松本润测试题"); s2.setScale_id(2);
		 * s2.setTest_time(time.parse("02:30:00")); s2.setTotal_score(150);
		 * s2.setManager_id(3); s3.setName("所谓测试题"); s3.setScale_id(3);
		 * s3.setTest_time(time.parse("03:00:00")); s3.setTotal_score(120);
		 * s3.setManager_id(2); s4.setName("本田测试题"); s4.setScale_id(4);
		 * s4.setTest_time(time.parse("01:30:00")); s4.setTotal_score(100);
		 * s4.setManager_id(1); List<Scale> scales= new ArrayList<Scale>();
		 * scales.add(s1); scales.add(s2); scales.add(s3); scales.add(s4);
		 * String str_scale=null; for(Scale s:scales){ str_scale
		 * JSON.parseArray(); }
		 */
		/*
		 * HttpSession session=request.getSession();
		 * session.setAttribute("scales", scales);
		 */

		out.flush();
		out.close();
	}

}
